<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdminGoodsEditRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'good_name' => 'required|min:3|max:100',
            'price' => 'required|numeric',
            'brand' => 'required',
            'type' => 'required',
            'good_desc' => 'required',
            'content' => 'required',
        ];
    }


    public function messages()
    {
        return [
            'good_name.required' => '商品名称不能为空',
            'good_name.min' => '商品名称不能小于3个字符',
            'good_name.max' => '商品名称不能大于100个字符',
            'price.required' => '商品价格不能为空',
            'price.numeric' => '商品价格只能是数字',
            'brand.required' => '请选择所属品牌',
            'type.required' => '请选择所属分类',
            'good_desc.required' => '商品描述不能为空',
            'content.required' => '详细内容不能为空',
        ];
    }
}
